package com.wgq.IO;

import java.io.File;
import java.io.IOException;

public class File_Dome
{
    public static  void path()
    {
        System.out.println(File.pathSeparator);  //路径分隔符 ";"
        System.out.println(File.separator);     //文件分隔符  "\"

        String  path1 = "C:\\Users\\ACER\\Desktop\\java\\jdk1.8中文版.CHM";

        String path2 = "C:/Users/ACER/Desktop/java/jdk1.8中文版.CHM";

        String path3 = "C:"+File.separator+"Users"+
        File.separator+"Desktop"+File.separator+
        "java"+File.separator+"jdk1.8中文版.CHM";

        System.out.println(path1+"\n"+path2+"\n"+path3);
    }

    public static void getName()
    {
        String path1 = "C:/Users/ACER/Desktop/java/jdk1.8中文版.CHM";
        File file = new File(path1);
        System.out.println(file.getName());
        System.out.println(file.getPath());         //相对路径
        System.out.println(file.getAbsolutePath());     //绝对路径
        System.out.println("----------------------------");
        String path2 = "1.txt";
        File file1 = new File(path2);
        try {
            file1.createNewFile();
        } catch (IOException e) {
            e.printStackTrace();
        }
        System.out.println(file1.getName());
        System.out.println(file1.getPath());
        System.out.println(file1.getAbsolutePath());
        System.out.println(file1.exists());

    }
    public static void main(String[] args)
    {
        //getName();

    }
}
